//
//  XSQSubCell.m
//  BuDeJie
//
//  Created by Sem on 2018/6/28.
//  Copyright © 2018年 SEM. All rights reserved.
//

#import "XSQSubCell.h"
@interface XSQSubCell()
@property (weak, nonatomic) IBOutlet UILabel *titleLal;
@property (weak, nonatomic) IBOutlet UILabel *detailLal;
@property (weak, nonatomic) IBOutlet UIImageView *subImageView;

@end
@implementation XSQSubCell
- (void)setTagModel:(XSQSubTagModel *)tagModel{
    _tagModel =tagModel;
    self.titleLal.text =tagModel.theme_name;
    NSString *ss =@"";
    if(tagModel.sub_number.floatValue>10000){
        ss = [NSString stringWithFormat:@"%.1f万人订阅",tagModel.sub_number.floatValue/10000.0];
        ss = [ss stringByReplacingOccurrencesOfString:@".0" withString:@""];
    }else{
        ss=[NSString stringWithFormat:@"%@人订阅",tagModel.sub_number];
    }
    self.detailLal.text =ss;
    [self.subImageView sd_setImageWithURL:[NSURL URLWithString:tagModel.image_list] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
        //开始上下文
        UIGraphicsBeginImageContextWithOptions(image.size, NO, 0);
        //设定裁剪区域
        UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, image.size.width, image.size.height)];
        [path addClip];
        //画图
        [image drawAtPoint:CGPointZero];
        //获取image
        image = UIGraphicsGetImageFromCurrentImageContext();
        //关闭上下文
        UIGraphicsEndImageContext();
        self.subImageView.image=image;
    }];
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
- (void)setFrame:(CGRect)frame{
    frame.size.height=frame.size.height-1;
    [super setFrame:frame];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
